home *** CD-ROM | disk | FTP | other *** search
/ PC Master 5 / PC MASTER 5.iso / INTERNET / KIT / WIN95 / MSIE30.EXE / ieakjava.exe / classr.exe / com / ms / awt / image / ByteArrayImageSource.class (.txt)
Encoding:
Java Class File  |  1997-01-31  |  1.4 KB  |  49 lines

  1. package com.ms.awt.image;
  2.  
  3. import java.io.BufferedInputStream;
  4. import java.io.ByteArrayInputStream;
  5. import sun.awt.image.GifImageDecoder;
  6. import sun.awt.image.ImageDecoder;
  7. import sun.awt.image.InputStreamImageSource;
  8. import sun.awt.image.JPEGImageDecoder;
  9. import sun.awt.image.XbmImageDecoder;
  10.  
  11. public class ByteArrayImageSource extends InputStreamImageSource {
  12.    String imagefile;
  13.    byte[] data;
  14.  
  15.    public ByteArrayImageSource(String var1, byte[] var2) {
  16.       if (var1 != null && var2 != null) {
  17.          this.imagefile = var1;
  18.          this.data = var2;
  19.       } else {
  20.          throw new NullPointerException();
  21.       }
  22.    }
  23.  
  24.    final boolean checkSecurity(Object var1, boolean var2) {
  25.       return true;
  26.    }
  27.  
  28.    protected ImageDecoder getDecoder() {
  29.       BufferedInputStream var1 = new BufferedInputStream(new ByteArrayInputStream(this.data));
  30.       int var2 = this.imagefile.lastIndexOf(46);
  31.       if (var2 >= 0) {
  32.          String var3 = this.imagefile.substring(var2 + 1).toLowerCase();
  33.          if (var3.equals("gif")) {
  34.             return new GifImageDecoder(this, var1);
  35.          }
  36.  
  37.          if (var3.equals("jpeg") || var3.equals("jpg") || var3.equals("jpe") || var3.equals("jfif")) {
  38.             return new JPEGImageDecoder(this, var1);
  39.          }
  40.  
  41.          if (var3.equals("xbm")) {
  42.             return new XbmImageDecoder(this, var1);
  43.          }
  44.       }
  45.  
  46.       return ((InputStreamImageSource)this).getDecoder(var1);
  47.    }
  48. }
  49.